package org.zecontech.plantvszombie.client.model;

import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelLayerLocation;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
import net.minecraft.client.model.geom.builders.CubeDeformation;
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.client.renderer.entity.state.LivingEntityRenderState;
import net.minecraft.world.entity.Entity;
import org.zecontech.plantvszombie.util.Helpers;

public class CherryBombModel<T extends Entity> extends EntityModel<LivingEntityRenderState> {

    public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(Helpers.identifier("cherry_bomb"), "main");

    public final ModelPart Stem;

    public final ModelPart Bodies;

    public final ModelPart Leaves;

    public CherryBombModel(ModelPart modelPart) {
        super(modelPart);
        this.Stem = root.getChild("Stem");
        this.Bodies = root.getChild("Bodies");
        this.Leaves = root.getChild("Leaves");
    }

    public static LayerDefinition createBodyLayer() {
        MeshDefinition meshdefinition = new MeshDefinition();
        PartDefinition partdefinition = meshdefinition.getRoot();
        PartDefinition Stem = partdefinition.addOrReplaceChild("Stem", CubeListBuilder.create(),
                PartPose.offsetAndRotation(-4.0F, 16.0F, 0.0F, 0.0F, 0.1745F, 0.0F));
        PartDefinition Smallstem = Stem.addOrReplaceChild("Smallstem", CubeListBuilder.create(),
                PartPose.offsetAndRotation(8.0F, 3.0F, -1.0F, 0.0F, 0.0F, -0.6981F));
        PartDefinition SmallStem_r1 = Smallstem.addOrReplaceChild("SmallStem_r1",
                CubeListBuilder.create().texOffs(0, 1).addBox(0.5231F, -1.2095F, -0.6068F, 1.0F, 5.0F, 1.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(1.6529F, -9.561F, 1.6168F, 0.1015F, -0.1201F, -0.2941F));
        PartDefinition SmallStem_r2 = Smallstem.addOrReplaceChild("SmallStem_r2",
                CubeListBuilder.create().texOffs(0, 4).addBox(0.5231F, 3.7905F, -0.6168F, 1.0F, 4.0F, 1.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(3.0481F, -10.2546F, 1.6168F, 0.1015F, -0.1201F, 0.0986F));
        PartDefinition LargeStem = Stem.addOrReplaceChild("LargeStem", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.6981F));
        PartDefinition LargeStem_r1 = LargeStem.addOrReplaceChild("LargeStem_r1",
                CubeListBuilder.create().texOffs(0, 0).addBox(-0.1F, -4.0F, -0.5F, 1.0F, 8.0F, 1.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(-2.5309F, -4.5979F, 0.0667F, -0.1887F, -0.1376F, 0.0061F));
        PartDefinition Bodies = partdefinition.addOrReplaceChild("Bodies",
                CubeListBuilder.create().texOffs(0, 0).addBox(-7.0F, -10.5F, -1.0F, 10.0F, 10.0F, 10.0F, new CubeDeformation(0.0F)),
                PartPose.rotation(-3.0F, 24.0F, -4.0F));
        PartDefinition Cherry2 = Bodies.addOrReplaceChild("Cherry2",
                CubeListBuilder.create().texOffs(0, 20).addBox(-2.0F, -9.0F, 1.0F, 9.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(6.0F, 0.0F, -1.0F, 0.0F, 0.0F, -0.0873F));
        PartDefinition Leaves = partdefinition.addOrReplaceChild("Leaves", CubeListBuilder.create(), PartPose.rotation(0.0F, 24.0F, 0.0F));
        PartDefinition rightleaf = Leaves.addOrReplaceChild("rightleaf", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, -13.0F, 0.0F, -0.3491F, -2.0944F, 0.0F));
        PartDefinition RightLeaf_r1 = rightleaf.addOrReplaceChild("RightLeaf_r1",
                CubeListBuilder.create().texOffs(24, 0).addBox(-1.7802F, -1.642F, -0.1794F, 4.0F, 0.0F, 6.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.0663F, -1.7737F, -0.4327F, 0.004F, -0.4268F, -0.0541F));
        PartDefinition leftleaf = Leaves.addOrReplaceChild("leftleaf", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, -13.0F, 0.0F, -0.3491F, 2.0944F, 0.0F));
        PartDefinition LeftLeaf_r1 = leftleaf.addOrReplaceChild("LeftLeaf_r1",
                CubeListBuilder.create().texOffs(24, 0).addBox(-1.9609F, -1.4717F, -0.6513F, 4.0F, 0.0F, 6.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(0.1401F, -1.6515F, -0.7686F, 0.004F, -0.1475F, -0.0541F));
        PartDefinition middleleaf = Leaves.addOrReplaceChild("middleleaf", CubeListBuilder.create(),
                PartPose.offsetAndRotation(0.0F, -13.0F, 0.0F, -0.3491F, 0.0F, 0.0F));
        PartDefinition MiddleLeaf_r1 = middleleaf.addOrReplaceChild("MiddleLeaf_r1",
                CubeListBuilder.create().texOffs(24, 0).addBox(-2.2712F, -1.6189F, -0.2457F, 4.0F, 0.0F, 6.0F, new CubeDeformation(0.0F)),
                PartPose.offsetAndRotation(-0.2064F, -1.6907F, -0.6608F, 0.004F, 0.0095F, -0.0541F));
        return LayerDefinition.create(meshdefinition, 45, 45);
    }

}
